import os
from threading import *
from filetype import filetype

class mpg123thread(Thread):
    lastfile = ""
    def __init__(self, file):
        if file == "" or file == None:
            file = self.lastfile
        Thread.__init__(self)
        self.file = file
        self.lastfile = file
        self.running = False
    def run(self):
        bin = 'mpg123 ' + self.file
        b = os.popen(bin)
        b.readlines()
        self.running = False
    def play(self):
        self.running = True
        self.start()
    def stop(self):
        bin = 'killall mpg123'
        b = os.popen(bin)
        kill = b.readline()
        self.running = False

musicpath = 'media/music/'
tracks = filetype(musicpath)
notracks = False

if tracks.audio == []:
    notracks = True

music = None
playingmusic = False
